/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package proyecto.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
import org.springframework.web.servlet.view.RedirectView;
import proyecto.dao.EspecialidadDAO;
import proyecto.modelo.Especialidad;

/** 
 *
 * @author Administrador
 */
public class EspecialidadController extends MultiActionController {

    public EspecialidadController() {
        //Initialize controller properties here or 
        //in the Web Application Context

        //setCommandClass(MyCommand.class);
        //setCommandName("MyCommandName");
        //setSuccessView("successView");
        //setFormView("formView");
    }
    
   // @Override
    protected void doSubmitAction(Object command) throws Exception {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    private EspecialidadDAO especialidadDAO;

    public EspecialidadDAO getEspecialidadDAO() {
        return especialidadDAO;
    }

    public void setEspecialidadDAO(EspecialidadDAO especialidadDAO) {
        this.especialidadDAO = especialidadDAO;
    }

    public ModelAndView doInsertar(HttpServletRequest request, HttpServletResponse response) {
        Especialidad obj = new Especialidad();
        obj.setCodigo(request.getParameter("codigo"));
        obj.setNombre(request.getParameter("nombreesp"));

        especialidadDAO.insertar(obj);

       return new ModelAndView(new RedirectView("confirmar-datos-paciente.htm", true));
    }

    //Use onSubmit instead of doSubmitAction 
    //when you need access to the Request, Response, or BindException objects
    /*
    @Override
    protected ModelAndView onSubmit(
            HttpServletRequest request, 
            HttpServletResponse response, 
            Object command, 
            BindException errors) throws Exception {
        ModelAndView mv = new ModelAndView(getSuccessView());
        //Do something...
        return mv;
    }
    */

}